﻿CREATE FUNCTION [dbo].[fn_NumericScale]
(
	@Table   sysname,
	@Column  sysname
)
RETURNS SMALLINT
AS
BEGIN
	RETURN (
	    SELECT c.scale
	    FROM   sys.tables t
	           INNER JOIN sys.[columns] c
	                ON  t.[object_id] = c.[object_id]
	    WHERE  t.[name] = @Table
		       AND t.[type] = 'U'
	           AND c.[name] = @Column
	)
END